home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1995 April / Internet Tools.iso / applic / ntp / depredated / ntp.3.4 / patches / patch7.Z / patch7
Encoding:
Text File  |  1991-09-29  |  23.7 KB  |  886 lines

  1. System: ntp version 3.4
  2. Patch #: 7
  3. Priority: 
  4. From:
  5. Description:
  6. Add definition of NOSWAP for Ultrix systems.
  7. Removed unused variables from ntp.c program.
  8. Removed unused variable from ntp_adjust.c module.
  9. Don't clear peer.reach register in the clear() procedure.  Code to prevent
  10. flapping between two peers with very similar dispersions.
  11. Deleted unused variables in ntp_sock.c
  12. Added NOSWAP code for Ultrix systems to lock NTP process in memory.  Deleted
  13. unused variable in ntpd.c
  14. In stat.pl, handle ntpd log files that cross months.
  15. Add check for SUN_FLT_BUG problem in test.c
  16.  
  17. Repeat-By:
  18.  
  19. Fix:    From rn, say "| patch -p -N -d DIR", where DIR is your ntp source
  20.     directory.  Outside of rn, say "cd DIR; patch -p -N <thisarticle".
  21.     If you don't have the patch program, apply the following by hand,
  22.     or get patch (version 2.0, latest patchlevel).
  23.  
  24.     After patching:
  25.         make depend
  26.         make
  27.         make install
  28.  
  29.     If patch indicates that patchlevel is the wrong version, you may need
  30.     to apply one or more previous patches, or the patch may already
  31.     have been applied.  See the patchlevel.h file to find out what has or
  32.     has not been applied.  In any event, don't continue with the patch.
  33.  
  34.     If you are missing previous patches they can be obtained from me:
  35.  
  36.     Louis A. Mamakos
  37.     louie@trantor.umd.edu
  38.  
  39.     You can also get the patches via anonymous FTP from
  40.     trantor.umd.edu.
  41.  
  42. Index: patchlevel.h
  43. Prereq: 6
  44. 1c1
  45. < #define PATCHLEVEL 6
  46. ---
  47. > #define PATCHLEVEL 7
  48.  
  49. Index: Makefile
  50. *** Makefile.old    Fri Apr  7 19:10:46 1989
  51. --- Makefile    Fri Apr  7 19:10:47 1989
  52. ***************
  53. *** 1,6 ****
  54. ! # $Source: /usr/users/louie/ntp/RCS/Makefile,v $ $Revision: 3.4.1.3 $ $Date: 89/03/29 12:21:27 $
  55.   #
  56.   # $Log:    Makefile,v $
  57.   # Revision 3.4.1.3  89/03/29  12:21:27  louie
  58.   # Don't bother to create the Version file for the distribution any longer.
  59.   # Define SUN_FLT_BUG rather than just 'sun' to get the a fix for a floating
  60. --- 1,9 ----
  61. ! # $Source: /usr/users/louie/ntp/RCS/Makefile,v $ $Revision: 3.4.1.4 $ $Date: 89/04/07 18:04:14 $
  62.   #
  63.   # $Log:    Makefile,v $
  64. + # Revision 3.4.1.4  89/04/07  18:04:14  louie
  65. + # Add definition of NOSWAP for Ultrix systems.
  66. + # 
  67.   # Revision 3.4.1.3  89/03/29  12:21:27  louie
  68.   # Don't bother to create the Version file for the distribution any longer.
  69.   # Define SUN_FLT_BUG rather than just 'sun' to get the a fix for a floating
  70. ***************
  71. *** 71,76 ****
  72. --- 74,80 ----
  73.   #    LOG_NTP=foo - to change the syslog facility.  You could specify
  74.   #            something like -DLOG_NTP=LOG_LOCAL3 to log into the
  75.   #            LOG_LOCAL3 syslog facility
  76. + #    NOSWAP - allow use of plock() to prevent swapping
  77.   #
  78.   
  79.   # FEATURES=
  80. ***************
  81. *** 87,93 ****
  82.   # it should be declared as a u_long not a in_addr  (the doc is wrong also)
  83.   # (Note 3.0 has it fixed).  VAX_COMPILER_FLT_BUG is defined for pcc which
  84.   # doesn't know how to convert an unsigned long into a float/double
  85. ! #DEFINES= -DVAX_COMPILER_FLT_BUG
  86.   
  87.   CFLAGS= -O ${DEFINES} ${FEATURES} ${INCPATH}
  88.   #
  89. --- 91,97 ----
  90.   # it should be declared as a u_long not a in_addr  (the doc is wrong also)
  91.   # (Note 3.0 has it fixed).  VAX_COMPILER_FLT_BUG is defined for pcc which
  92.   # doesn't know how to convert an unsigned long into a float/double
  93. ! #DEFINES= -DVAX_COMPILER_FLT_BUG -DNOSWAP
  94.   
  95.   CFLAGS= -O ${DEFINES} ${FEATURES} ${INCPATH}
  96.   #
  97.  
  98. Index: ntp.c
  99. *** ntp.c.old    Fri Apr  7 19:10:51 1989
  100. --- ntp.c    Fri Apr  7 19:10:53 1989
  101. ***************
  102. *** 1,9 ****
  103.   #ifndef    lint
  104. ! static char *rcsid = "$Source: /usr/users/louie/ntp/RCS/ntp.c,v $ $Revision: 3.4.1.3 $ $Date: 89/03/22 18:29:22 $";
  105.   #endif    lint
  106.   
  107.   /*
  108.    *  $Log:    ntp.c,v $
  109.    * Revision 3.4.1.3  89/03/22  18:29:22  louie
  110.    * patch3: Use new RCS headers.
  111.    * 
  112. --- 1,12 ----
  113.   #ifndef    lint
  114. ! static char *rcsid = "$Source: /usr/users/louie/ntp/RCS/ntp.c,v $ $Revision: 3.4.1.4 $ $Date: 89/04/07 18:04:49 $";
  115.   #endif    lint
  116.   
  117.   /*
  118.    *  $Log:    ntp.c,v $
  119. +  * Revision 3.4.1.4  89/04/07  18:04:49  louie
  120. +  * Removed unused variables from ntp.c program.
  121. +  * 
  122.    * Revision 3.4.1.3  89/03/22  18:29:22  louie
  123.    * patch3: Use new RCS headers.
  124.    * 
  125. ***************
  126. *** 123,133 ****
  127.       struct l_fixedpt in_timestamp;
  128.       static struct ntpdata ntp_data;
  129.       struct ntpdata *pkt = &ntp_data;
  130. !     struct timeval tp, tp1, timeout;
  131.       int host, n, retry, s;
  132.       fd_set readfds;
  133.       int dstlen = sizeof(dst);
  134. !     double ref, t1, t2, t3, t4, offset, delay;
  135.       char ref_clock[5];
  136.       time_t net_time;
  137.       ref_clock[4] = NULL;
  138. --- 126,136 ----
  139.       struct l_fixedpt in_timestamp;
  140.       static struct ntpdata ntp_data;
  141.       struct ntpdata *pkt = &ntp_data;
  142. !     struct timeval tp, timeout;
  143.       int host, n, retry, s;
  144.       fd_set readfds;
  145.       int dstlen = sizeof(dst);
  146. !     double t1, t2, t3, t4, offset, delay;
  147.       char ref_clock[5];
  148.       time_t net_time;
  149.       ref_clock[4] = NULL;
  150. ***************
  151. *** 327,333 ****
  152.   
  153.           /* set the clock */
  154.           gettimeofday(&tp, (struct timezone *) 0);
  155. -         tp1 = tp;
  156.           offset += tp.tv_sec;
  157.           offset += tp.tv_usec / 1000000.0;
  158.           tp.tv_sec = offset;
  159. --- 330,335 ----
  160.  
  161. Index: ntp_adjust.c
  162. *** ntp_adjust.c.old    Fri Apr  7 19:10:57 1989
  163. --- ntp_adjust.c    Fri Apr  7 19:10:58 1989
  164. ***************
  165. *** 1,5 ****
  166.   #ifndef lint
  167. ! static char *RCSid = "$Source: /usr/users/louie/ntp/RCS/ntp_adjust.c,v $ $Revision: 3.4.1.2 $ $Date: 89/03/22 18:30:52 $";
  168.   #endif
  169.   
  170.   /*
  171. --- 1,5 ----
  172.   #ifndef lint
  173. ! static char *RCSid = "$Source: /usr/users/louie/ntp/RCS/ntp_adjust.c,v $ $Revision: 3.4.1.3 $ $Date: 89/04/07 18:05:17 $";
  174.   #endif
  175.   
  176.   /*
  177. ***************
  178. *** 7,12 ****
  179. --- 7,15 ----
  180.    * 5. of the NTP specification.
  181.    *
  182.    * $Log:    ntp_adjust.c,v $
  183. +  * Revision 3.4.1.3  89/04/07  18:05:17  louie
  184. +  * Removed unused variable from ntp_adjust.c module.
  185. +  * 
  186.    * Revision 3.4.1.2  89/03/22  18:30:52  louie
  187.    * patch3: Use new RCS headers.
  188.    * 
  189. ***************
  190. *** 130,136 ****
  191.       double offset;
  192.   {
  193.       struct timeval tv2;
  194. -     int i;
  195.   #ifdef    XADJTIME2
  196.       struct timeval delta, olddelta;
  197.   #endif
  198. --- 133,138 ----
  199.  
  200. Index: ntp_proto.c
  201. *** ntp_proto.c.old    Fri Apr  7 19:11:05 1989
  202. --- ntp_proto.c    Fri Apr  7 19:11:07 1989
  203. ***************
  204. *** 1,5 ****
  205.   #ifndef    lint
  206. ! static char *rcsid = "$Source: /usr/users/louie/ntp/RCS/ntp_proto.c,v $ $Revision: 3.4.1.5 $ $Date: 89/03/31 16:36:38 $";
  207.   #endif
  208.   
  209.   /*
  210. --- 1,5 ----
  211.   #ifndef    lint
  212. ! static char *rcsid = "$Source: /usr/users/louie/ntp/RCS/ntp_proto.c,v $ $Revision: 3.4.1.6 $ $Date: 89/04/07 19:07:10 $";
  213.   #endif
  214.   
  215.   /*
  216. ***************
  217. *** 7,15 ****
  218.    * It contains a minimum of machine and operating system dependencies (or at
  219.    * least that's the idea).  Setup of UDP sockets, timers, etc is done in the
  220.    * ntpd.c module, while arithmetic conversion routines are in ntpsubs.c
  221. !  *
  222. !  *
  223.    * $Log:    ntp_proto.c,v $
  224.    * Revision 3.4.1.5  89/03/31  16:36:38  louie
  225.    * There is now a run-time option that can be specified in the configuration 
  226.    * which specifies if we will synchronize to unconfigured hosts.  Fixes to
  227. --- 7,20 ----
  228.    * It contains a minimum of machine and operating system dependencies (or at
  229.    * least that's the idea).  Setup of UDP sockets, timers, etc is done in the
  230.    * ntpd.c module, while arithmetic conversion routines are in ntpsubs.c
  231. !  */
  232. ! /*
  233.    * $Log:    ntp_proto.c,v $
  234. +  * Revision 3.4.1.6  89/04/07  19:07:10  louie
  235. +  * Don't clear peer.reach register in the clear() procedure.  Code to prevent
  236. +  * flapping between two peers with very similar dispersions.
  237. +  * 
  238.    * Revision 3.4.1.5  89/03/31  16:36:38  louie
  239.    * There is now a run-time option that can be specified in the configuration 
  240.    * which specifies if we will synchronize to unconfigured hosts.  Fixes to
  241. ***************
  242. *** 306,311 ****
  243. --- 311,317 ----
  244.           peer->src = *dst;
  245.           peer->sock = sock;
  246.           peer->hmode = MODE_SYM_PAS;
  247. +         peer->reach = 0;
  248.           clear(peer);
  249.       } else
  250.           peer = check_peer(dst, sock);
  251. ***************
  252. *** 321,328 ****
  253.           peer->sock = sock;    /* remember which socket we heard 
  254.                          this from */
  255.           peer->hmode = MODE_SYM_PAS;
  256.           clear(peer);
  257. - #if    1
  258.           /*
  259.            *  If we decide to consider any random NTP peer that might
  260.            *  come as a peer we might sync to, then set the PEER_FL_SYNC
  261. --- 327,334 ----
  262.           peer->sock = sock;    /* remember which socket we heard 
  263.                          this from */
  264.           peer->hmode = MODE_SYM_PAS;
  265. +         peer->reach = 0;
  266.           clear(peer);
  267.           /*
  268.            *  If we decide to consider any random NTP peer that might
  269.            *  come as a peer we might sync to, then set the PEER_FL_SYNC
  270. ***************
  271. *** 333,339 ****
  272.            */
  273.           if (trusting)
  274.               peer->flags |= PEER_FL_SYNC;
  275. - #endif
  276.   
  277.           enqueue(&peer_list, peer);
  278.       }
  279. --- 339,344 ----
  280. ***************
  281. *** 654,660 ****
  282.       for (i = 0; i < NTP_WINDOW; i++)
  283.           peer->filter.offset[i] = 0.0;
  284.       peer->filter.samples = 0;    /* Implementation specific */
  285. -     peer->reach = 0;
  286.       peer->valid = 0;
  287.       peer->org.int_part = peer->org.fraction = 0;
  288.       peer->rec.int_part = peer->rec.fraction = 0;
  289. --- 659,664 ----
  290. ***************
  291. *** 995,1000 ****
  292. --- 999,1031 ----
  293.                      ntoa(sel_lst[0].peer->src.sin_addr),
  294.                      sel_lst[0].peer->stratum);
  295.       }
  296. +     if (sys.peer != NULL && sys.peer != sel_lst[0].peer) {
  297. +         /* 
  298. +          * Potential peer is different that current one; don't switch
  299. +          * to new peer unless the offset is suitably "large".
  300. +          */
  301. +         if (sys.peer->stratum == sel_lst[0].peer->stratum) {
  302. +             double threshold ;
  303. +             threshold = NTP_MAXSKW +
  304. +                 1.0/(unsigned long)(1L << -sys.precision);
  305. +             /* make sure we don't try to divide by zero */
  306. +             if (-sel_lst[0].peer->precision < sizeof(long))
  307. +                 threshold += 1.0/(unsigned long)
  308. +                     (1L << -sel_lst[0].peer->precision);
  309. +             if (sel_lst[0].peer->estoffset < threshold) {
  310. + #ifdef    DEBUG
  311. +                 if (debug > 2)
  312. +                     printf("clock: inhibit peer switch\n");
  313. + #endif
  314. +                 return;
  315. +             }
  316. +         }         
  317. +     }
  318.   #ifdef    DEBUG
  319.       if ((debug > 2) || (sys.peer != sel_lst[0].peer))
  320.           printf("clock: select peer %s stratum %d\n",
  321.  
  322. Index: ntp_sock.c
  323. *** ntp_sock.c.old    Fri Apr  7 19:11:12 1989
  324. --- ntp_sock.c    Fri Apr  7 19:11:13 1989
  325. ***************
  326. *** 1,9 ****
  327.   #ifndef    lint
  328. ! static char *RCSid = "$Source: /usr/users/louie/ntp/RCS/ntp_sock.c,v $ $Revision: 3.4.1.1 $ $Date: 89/03/22 18:31:20 $";
  329.   #endif
  330.   
  331.   /*
  332.    * $Log:    ntp_sock.c,v $
  333.    * Revision 3.4.1.1  89/03/22  18:31:20  louie
  334.    * patch3: Use new RCS headers.
  335.    * 
  336. --- 1,12 ----
  337.   #ifndef    lint
  338. ! static char *RCSid = "$Source: /usr/users/louie/ntp/RCS/ntp_sock.c,v $ $Revision: 3.4.1.2 $ $Date: 89/04/07 19:07:46 $";
  339.   #endif
  340.   
  341.   /*
  342.    * $Log:    ntp_sock.c,v $
  343. +  * Revision 3.4.1.2  89/04/07  19:07:46  louie
  344. +  * Deleted unused variables in ntp_sock.c
  345. +  * 
  346.    * Revision 3.4.1.1  89/03/22  18:31:20  louie
  347.    * patch3: Use new RCS headers.
  348.    * 
  349. ***************
  350. *** 148,154 ****
  351.       struct    ifreq    ifreq, *ifr;
  352.       int on = 1, off = 0;
  353.       int n, i, vs;
  354. -     struct sockaddr_in sock;
  355.       extern char *malloc();
  356.   
  357.       /*
  358. --- 151,156 ----
  359. ***************
  360. *** 162,171 ****
  361.   
  362.       nintf = 1;
  363.   
  364. -     sock.sin_family = AF_INET;
  365. -     sock.sin_port = port;
  366. -     sock.sin_addr.s_addr = INADDR_ANY;
  367.       if ((vs = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
  368.           syslog(LOG_ERR, "vs=socket(AF_INET, SOCK_DGRAM) %m");
  369.   #ifdef    TEST
  370. --- 164,169 ----
  371. ***************
  372. *** 317,322 ****
  373. --- 315,321 ----
  374.            *  is being bound anyway..
  375.            */
  376.           if (setsockopt(addrs[i].fd, SOL_SOCKET, SO_REUSEADDR,
  377.                      (char *)&off, sizeof(off))) {
  378.               syslog(LOG_ERR, "setsockopt SO_REUSEADDR off fails: %m");
  379.   #ifdef    TEST
  380.  
  381. Index: ntpd.c
  382. *** ntpd.c.old    Fri Apr  7 19:11:20 1989
  383. --- ntpd.c    Fri Apr  7 19:11:23 1989
  384. ***************
  385. *** 1,9 ****
  386.   #ifndef    lint
  387. ! static char *rcsid = "$Source: /usr/users/louie/ntp/RCS/ntpd.c,v $ $Revision: 3.4.1.5 $ $Date: 89/03/31 16:37:49 $";
  388.   #endif    lint
  389.   
  390.   /*
  391.    *  $Log:    ntpd.c,v $
  392.    * Revision 3.4.1.5  89/03/31  16:37:49  louie
  393.    * Add support for "trusting" directive in NTP configuration file.  It allows 
  394.    * you to specify at run time if non-configured peers will be synced to.
  395. --- 1,13 ----
  396.   #ifndef    lint
  397. ! static char *rcsid = "$Source: /usr/users/louie/ntp/RCS/ntpd.c,v $ $Revision: 3.4.1.6 $ $Date: 89/04/07 19:09:04 $";
  398.   #endif    lint
  399.   
  400.   /*
  401.    *  $Log:    ntpd.c,v $
  402. +  * Revision 3.4.1.6  89/04/07  19:09:04  louie
  403. +  * Added NOSWAP code for Ultrix systems to lock NTP process in memory.  Deleted
  404. +  * unused variable in ntpd.c
  405. +  * 
  406.    * Revision 3.4.1.5  89/03/31  16:37:49  louie
  407.    * Add support for "trusting" directive in NTP configuration file.  It allows 
  408.    * you to specify at run time if non-configured peers will be synced to.
  409. ***************
  410. *** 73,78 ****
  411. --- 77,85 ----
  412.   #include <sys/ioctl.h>
  413.   #include <sys/resource.h>
  414.   #include <sys/file.h>
  415. + #ifdef NOSWAP
  416. + #include <sys/lock.h>
  417. + #endif
  418.   
  419.   #include <net/if.h>
  420.   
  421. ***************
  422. *** 115,120 ****
  423. --- 122,131 ----
  424.   int    dotickadj = 0;
  425.   #endif
  426.   
  427. + #ifdef    NOSWAP
  428. + int    noswap = 0;
  429. + #endif
  430.   int doset = 1;
  431.   int ticked;
  432.   int selfds;
  433. ***************
  434. *** 130,136 ****
  435.   extern char *malloc(), *ntoa();
  436.   extern double s_fixed_to_double(), ul_fixed_to_double();
  437.   
  438. ! void finish(), timeout(), tock(), make_new_peer(), init_ntp(), 
  439.       init_kern_vars(), hourly();
  440.   extern void transmit(), process_packet(), clock_update(),
  441.       clear(), clock_filter(), select_clock();
  442. --- 141,147 ----
  443.   extern char *malloc(), *ntoa();
  444.   extern double s_fixed_to_double(), ul_fixed_to_double();
  445.   
  446. ! void finish(), timeout(), tock(), make_new_peer(), init_ntp(), initialize(),
  447.       init_kern_vars(), hourly();
  448.   extern void transmit(), process_packet(), clock_update(),
  449.       clear(), clock_filter(), select_clock();
  450. ***************
  451. *** 157,163 ****
  452.                      then allow others to override default
  453.                      values */
  454.       prog_name = argv[0];
  455. !     while ((cc = getopt(argc, argv, "a:c:dD:st")) != EOF) {
  456.           switch (cc) {
  457.           case 'a':
  458.               if (strcmp(optarg, "any") == 0)
  459. --- 168,174 ----
  460.                      then allow others to override default
  461.                      values */
  462.       prog_name = argv[0];
  463. !     while ((cc = getopt(argc, argv, "a:c:dD:stn")) != EOF) {
  464.           switch (cc) {
  465.           case 'a':
  466.               if (strcmp(optarg, "any") == 0)
  467. ***************
  468. *** 197,202 ****
  469. --- 208,222 ----
  470.   #endif
  471.               break;
  472.   
  473. +         case 'n':
  474. + #ifdef    NOSWAP
  475. +             noswap = 1;
  476. + #else
  477. +             fprintf(stderr, "%s: not compiled for noswap\n",
  478. +                 prog_name);
  479. + #endif
  480. +             break;
  481.           case 'c':
  482.               conf = optarg;
  483.               break;
  484. ***************
  485. *** 247,262 ****
  486.           setlogmask(LOG_UPTO(LOG_INFO));
  487.   #endif    /* LOG_DAEMON */
  488.   
  489. !     syslog(LOG_NOTICE, "%s version $Revision: 3.4.1.5 $", prog_name);
  490.       syslog(LOG_NOTICE, "patchlevel %d", PATCHLEVEL);
  491.   
  492.   #ifdef    DEBUG
  493.       if (debug)
  494. !         printf("%s version $Revision: 3.4.1.5 $ patchlevel %d\n",
  495.                  prog_name, PATCHLEVEL);
  496.   #endif
  497.       (void) setpriority(PRIO_PROCESS, 0, -10);
  498.   
  499.       servp = getservbyname("ntp", "udp");
  500.       if (servp == NULL) {
  501.           syslog(LOG_CRIT, "udp/ntp: service unknown, using default %d",
  502. --- 267,293 ----
  503.           setlogmask(LOG_UPTO(LOG_INFO));
  504.   #endif    /* LOG_DAEMON */
  505.   
  506. !     syslog(LOG_NOTICE, "%s version $Revision: 3.4.1.6 $", prog_name);
  507.       syslog(LOG_NOTICE, "patchlevel %d", PATCHLEVEL);
  508.   
  509.   #ifdef    DEBUG
  510.       if (debug)
  511. !         printf("%s version $Revision: 3.4.1.6 $ patchlevel %d\n",
  512.                  prog_name, PATCHLEVEL);
  513.   #endif
  514.       (void) setpriority(PRIO_PROCESS, 0, -10);
  515.   
  516. + #ifdef    NOSWAP
  517. +     if (noswap)
  518. +         if (plock(PROCLOCK) != 0)  {
  519. +             syslog(LOG_ERR, "plock() failed: %m");
  520. + #ifdef    DEBUG
  521. +             if (debug)
  522. +                 perror("plock() failed");
  523. + #endif
  524. +         }
  525. + #endif
  526.       servp = getservbyname("ntp", "udp");
  527.       if (servp == NULL) {
  528.           syslog(LOG_CRIT, "udp/ntp: service unknown, using default %d",
  529. ***************
  530. *** 737,742 ****
  531. --- 768,777 ----
  532.                   error = TRUE;
  533.               else tickadj = i;
  534.   #endif
  535. + #ifdef    NOSWAP
  536. +         } else if (strcmp(name, "noswap") == 0) {
  537. +             noswap = 1;
  538. + #endif
  539.   #ifdef    BROADCAST_NTP
  540.           } else if (strcmp(name, "broadcast") == 0) {
  541.               if (fscanf(fp, "%s", name) != 1) {
  542. ***************
  543. *** 855,861 ****
  544.                   }
  545.               }
  546.               skipit:;
  547. !         }        /* end else ntppeer */
  548.           do
  549.               c = fgetc(fp);
  550.           while (c != '\n' && c != EOF);    /* next line */
  551. --- 890,902 ----
  552.                   }
  553.               }
  554.               skipit:;
  555. !         } else if( *name != '#' ) {
  556. !             syslog(LOG_ERR, "config file: %s not recognized", name);
  557. ! #ifdef DEBUG
  558. !             if(debug)
  559. !                 printf("unrecognized option in config file: %s\n", name);
  560. ! #endif
  561. !         }
  562.           do
  563.               c = fgetc(fp);
  564.           while (c != '\n' && c != EOF);    /* next line */
  565. ***************
  566. *** 1117,1123 ****
  567.   /* every hour, dump some useful information to the log */
  568.   void
  569.   hourly() {
  570. -     register struct ntp_peer *peer = peer_list.head;
  571.       char buf[200];
  572.       register int p = 0;
  573.       extern double drift_comp, compliance;
  574. --- 1158,1163 ----
  575.  
  576. Index: stat.pl
  577. *** stat.pl.old    Fri Apr  7 19:11:28 1989
  578. --- stat.pl    Fri Apr  7 19:11:29 1989
  579. ***************
  580. *** 1,5 ****
  581.   #!/usr/bin/perl  
  582. ! # $Source: /usr/users/louie/ntp/RCS/stat.pl,v $ $Revision: 3.4.1.4 $ $Date: 89/03/31 16:38:42 $
  583.   #
  584.   #  Make plots from ntpd syslog messages.  Invoked as:
  585.   #
  586. --- 1,5 ----
  587.   #!/usr/bin/perl  
  588. ! # $Source: /usr/users/louie/ntp/RCS/stat.pl,v $ $Revision: 3.4.1.5 $ $Date: 89/04/07 19:10:00 $
  589.   #
  590.   #  Make plots from ntpd syslog messages.  Invoked as:
  591.   #
  592. ***************
  593. *** 29,36 ****
  594.   #    off -0.015756 drft 0.000000 cmpl 0.000000
  595.   # Mar 10 08:56:19 trantor ntpd[27755]: clock: select peer 128.8.10.1 stratum 1
  596.   #    was 130.126.174.40 stratum 1
  597.   #
  598. - #
  599.   $scriptfile = $0;
  600.   
  601.   $month{'Jan'} = 0; $month{'Feb'} = 1; $month{'Mar'} = 2; $month{'Apr'} = 3;
  602. --- 29,37 ----
  603.   #    off -0.015756 drft 0.000000 cmpl 0.000000
  604.   # Mar 10 08:56:19 trantor ntpd[27755]: clock: select peer 128.8.10.1 stratum 1
  605.   #    was 130.126.174.40 stratum 1
  606. + # Mar 31 16:55:19 trantor ntpd[2195]: /usr/local/etc/ntpd version $Revision:
  607. + #    3.4.1.5 $#
  608.   #
  609.   $scriptfile = $0;
  610.   
  611.   $month{'Jan'} = 0; $month{'Feb'} = 1; $month{'Mar'} = 2; $month{'Apr'} = 3;
  612. ***************
  613. *** 37,42 ****
  614. --- 38,61 ----
  615.   $month{'May'} = 4; $month{'Jun'} = 5; $month{'Jul'} = 6; $month{'Aug'} = 7;
  616.   $month{'Sep'} = 8; $month{'Oct'} = 9; $month{'Nov'} = 10; $month{'Dec'} = 11;
  617.   
  618. + #
  619. + #  Currently, the year is not included in the syslog messages.  We'll have to
  620. + #  assume that the log files be processed were written this year.
  621. + #
  622. + ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
  623. + if ($year % 4) {
  624. +     # not leap year
  625. +     $days[0] = 0; $days[1] = 31; $days[2] = 59; $days[3] = 90;
  626. +     $days[4] = 120; $days[5] = 151; $days[6] = 181; $days[7] = 212;
  627. +     $days[8] = 243; $days[9] = 273; $days[10] = 304; $days[11] = 334; 
  628. + } else {
  629. +     # leap year
  630. +     $days[0] = 0; $days[1] = 31; $days[2] = 60; $days[3] = 91;
  631. +     $days[4] = 121; $days[5] = 152; $days[6] = 182; $days[7] = 213;
  632. +     $days[8] = 244; $days[9] = 274; $days[10] = 305; $days[11] = 335;
  633. + }
  634.   die "Can't open drift compansation file\n" unless open(DRIFT, ">stats.drift");
  635.   die "Can't open offset file\n" unless open(OFF, ">stats.off");
  636.   die "Can't open compliance file\n" unless open(COMP, ">stats.comp");
  637. ***************
  638. *** 66,78 ****
  639.   }
  640.   
  641.   while (<>) {
  642. !     if (/.* ntpd\[[0-9]*\]: *.ntpd version/) {
  643.           chop;
  644.           @in = split;
  645.           $recs++;
  646.   
  647.           @time = split(/:/,$in[2]);
  648. !         $t = $in[1]*24 + $time[0] + $time[1]/60 + $time[2]/3600;
  649.   
  650.           if (!$start) {
  651.               $start = $t;
  652. --- 85,101 ----
  653.   }
  654.   
  655.   while (<>) {
  656. !     if (/.* ntpd\[[0-9]*\]: (.*\/ntpd) version \$Revision: \b(.*)\b/) {
  657.           chop;
  658.           @in = split;
  659.           $recs++;
  660. +         $revision = $1 . " " . $2;
  661.   
  662. +         print "Revision $revision\n";
  663.           @time = split(/:/,$in[2]);
  664. !         $t = $in[1]*24 + $time[0] + $time[1]/60 + $time[2]/3600 +
  665. !             $days[$month{$in[0]}]*24;
  666.   
  667.           if (!$start) {
  668.               $start = $t;
  669. ***************
  670. *** 83,89 ****
  671.           chop;
  672.           @in = split;
  673.           @time = split(/:/,$in[2]);
  674. !         $t = $in[1]*24 + $time[0] + $time[1]/60 + $time[2]/3600;
  675.   
  676.           if (!$start) {
  677.               $start = $t;
  678. --- 106,113 ----
  679.           chop;
  680.           @in = split;
  681.           @time = split(/:/,$in[2]);
  682. !         $t = $in[1]*24 + $time[0] + $time[1]/60 + $time[2]/3600 +
  683. !             $days[$month{$in[0]}]*24;
  684.   
  685.           if (!$start) {
  686.               $start = $t;
  687. ***************
  688. *** 103,110 ****
  689.           $recs++;
  690.   
  691.           @time = split(/:/,$in[2]);
  692. !         $t = $in[1]*24 + $time[0] + $time[1]/60 + $time[2]/3600;
  693.           if (!$start) {
  694.               $start = $t;
  695.               printf "Start time is %s %s %s\n",$in[0],$in[1],$in[2];
  696. --- 127,134 ----
  697.           $recs++;
  698.   
  699.           @time = split(/:/,$in[2]);
  700. !         $t = $in[1]*24 + $time[0] + $time[1]/60 + $time[2]/3600 +
  701. !             $days[$month{$in[0]}]*24;
  702.           if (!$start) {
  703.               $start = $t;
  704.               printf "Start time is %s %s %s\n",$in[0],$in[1],$in[2];
  705.  
  706. Index: test.c
  707. *** test.c.old    Fri Apr  7 19:11:33 1989
  708. --- test.c    Fri Apr  7 19:11:33 1989
  709. ***************
  710. *** 1,9 ****
  711.   #ifndef    lint
  712. ! static char *RCSid = "$Source: /usr/users/louie/ntp/RCS/test.c,v $ $Revision: 3.4.1.2 $ $Date: 89/03/31 16:39:19 $";
  713.   #endif
  714.   
  715.   /*
  716.    * $Log:    test.c,v $
  717.    * Revision 3.4.1.2  89/03/31  16:39:19  louie
  718.    * Bug fix for VAX_COMPILER_FLT_BUG test, start of test for Sun problem.
  719.    * 
  720. --- 1,12 ----
  721.   #ifndef    lint
  722. ! static char *RCSid = "$Source: /usr/users/louie/ntp/RCS/test.c,v $ $Revision: 3.4.1.3 $ $Date: 89/04/07 19:10:41 $";
  723.   #endif
  724.   
  725.   /*
  726.    * $Log:    test.c,v $
  727. +  * Revision 3.4.1.3  89/04/07  19:10:41  louie
  728. +  * Add check for SUN_FLT_BUG problem in test.c
  729. +  * 
  730.    * Revision 3.4.1.2  89/03/31  16:39:19  louie
  731.    * Bug fix for VAX_COMPILER_FLT_BUG test, start of test for Sun problem.
  732.    * 
  733. ***************
  734. *** 57,65 ****
  735.   
  736.   #define    TRUE    1
  737.   #define    FALSE    0
  738. - #define    BSD_43
  739.   
  740. ! int test1(), test2(), test3();
  741.   
  742.   double value[8] = {5.1, -5.1, 1.5, -1.5, 0.5, -0.5, -0.05, 0.0};
  743.   main(argc, argv)
  744. --- 60,67 ----
  745.   
  746.   #define    TRUE    1
  747.   #define    FALSE    0
  748.   
  749. ! int test1(), test2(), test3(), test4();
  750.   
  751.   double value[8] = {5.1, -5.1, 1.5, -1.5, 0.5, -0.5, -0.05, 0.0};
  752.   main(argc, argv)
  753. ***************
  754. *** 67,80 ****
  755.       char **argv;
  756.   {
  757.       if (argc > 1 && strcmp(argv[1], "-v") == 0) {
  758. !         if (test1(1))
  759. !             exit(1);
  760. !         if (test2(1))
  761. !             exit(2);
  762. !         if (test3(1))
  763. !             exit(3);
  764. !         if (test4(1))
  765. !             exit(4);
  766.       } else {
  767.           if (test3(0))
  768.               exit(3);
  769. --- 69,78 ----
  770.       char **argv;
  771.   {
  772.       if (argc > 1 && strcmp(argv[1], "-v") == 0) {
  773. !         exit(test1(1)
  774. !              + test2(1)
  775. !              + test3(1)
  776. !              + test4(1));
  777.       } else {
  778.           if (test3(0))
  779.               exit(3);
  780. ***************
  781. *** 92,98 ****
  782.       struct l_fixedpt sample;
  783.       double s_fixed_to_double();
  784.       struct s_fixedpt s_sample;
  785. -     double x;
  786.   
  787.       for (i = 0; i < 8; i++) {
  788.           printf(" %4.2f ", value[i]);
  789. --- 90,95 ----
  790. ***************
  791. *** 126,132 ****
  792.   test3(v)
  793.       int v;
  794.   {
  795. !     unsigned long ul = 0x80000000;
  796.       double dbl;
  797.   
  798.       dbl = ul;
  799. --- 123,129 ----
  800.   test3(v)
  801.       int v;
  802.   {
  803. !     unsigned long ul = 0x80000001;
  804.       double dbl;
  805.   
  806.       dbl = ul;
  807. ***************
  808. *** 133,141 ****
  809.   #ifdef    VAX_COMPILER_FLT_BUG
  810.       if (dbl < 0.0) dbl += 4.294967296e9;
  811.   #endif
  812. !     if (dbl != 2147483648.0) {
  813.           printf("test3 fails: can't convert from unsigned long to float\n");
  814. !         printf("             (%lu != %f)\n", ul, dbl);
  815.           printf("Try defining VAX_COMPILER_FLT_BUG in the Makefile.\n");
  816.           return 1;
  817.       } else {
  818. --- 130,138 ----
  819.   #ifdef    VAX_COMPILER_FLT_BUG
  820.       if (dbl < 0.0) dbl += 4.294967296e9;
  821.   #endif
  822. !     if (dbl != 2147483649.0) {
  823.           printf("test3 fails: can't convert from unsigned long to float\n");
  824. !         printf("             (%lu != %15g)\n", ul, dbl);
  825.           printf("Try defining VAX_COMPILER_FLT_BUG in the Makefile.\n");
  826.           return 1;
  827.       } else {
  828. ***************
  829. *** 148,163 ****
  830.   test4(v)
  831.       int v;
  832.   {
  833. !     /* 
  834. !      * Need a test for the SUN 2^31 - 2^32 problem (in ntpsubs.c).  Anyone
  835. !      * with a Sun out there that can come up with one?
  836. !      *
  837. !      */
  838. !     if (0) {
  839.           printf("test4 fails:\n");
  840.           printf("Try defining SUN_FLT_BUG in the Makefile\n");
  841.           return 1;
  842.       }
  843. -     return 0;
  844.   }
  845. --- 145,168 ----
  846.   test4(v)
  847.       int v;
  848.   {
  849. !     double dbl = 1024.0 * 1024.0 * 1024.0;    /* 2^30 */
  850. ! #ifdef SUN_FLT_BUG
  851. !     int l = 1.5 * dbl;
  852. !     u_long ul = (l<<1);
  853. ! #else
  854. !     u_long ul = 3.0 * dbl;            /* between 2^31 and 2^32 */
  855. ! #endif
  856. !     if (v)
  857. !         printf("test4: 3.0*1024.0*1024.0*1024.0 = 0x%08x\n", ul);
  858. !     if (ul != 0xc0000000) {
  859.           printf("test4 fails:\n");
  860. +         printf("Can't convert unsigned long to double.\n");
  861.           printf("Try defining SUN_FLT_BUG in the Makefile\n");
  862.           return 1;
  863. +     } else {
  864. +         if (v)
  865. +             printf("test4 passes\n");
  866. +             return 0;
  867.       }
  868.   }
  869.